import java.util.concurrent.atomic.AtomicInteger;

public class ThreadDemo1 {
    public static void main(String[] args) throws InterruptedException {
        AtomicInteger atomicInteger = new AtomicInteger(0);
        Thread thread1 = new Thread(() -> {
            for(int i = 0; i < 100; i ++) {
                atomicInteger.getAndIncrement();
            }
        });
        Thread thread2 = new Thread(() -> {
            for(int i = 0; i < 100; i ++) {
                atomicInteger.getAndIncrement();
            }
        });
        thread2.start();
        thread1.start();
        thread1.join();
        thread2.join();
        System.out.println(atomicInteger);
    }
}
